//
//  SearchViewController.swift
//  LaiLang
//
//  Created by David on 2017/2/21.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class SearchViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {

    var collectionView: UICollectionView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.groupTableViewBackground
        let navbar = LLAdaptHideNavBar(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: 64), title: "搜索", navigator: navigationController)
        
        let collectLayout = UICollectionViewFlowLayout()
        collectLayout.itemSize = CGSize(width: 80, height: 20)
        collectLayout.minimumInteritemSpacing = 8
        collectLayout.scrollDirection = .vertical
        
        collectionView = UICollectionView(frame: CGRect(x: 0, y: 44, width: view.bounds.width, height: view.bounds.height - 44), collectionViewLayout: collectLayout)
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "tag")
        view.addSubview(collectionView)
        
        view.addSubview(navbar)
//        let collectionLayout
        
    }

    func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 2
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 10
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: 80 + CGFloat(indexPath.row*10), height: 20)
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "tag", for: indexPath)
        cell.backgroundColor = UIColor.green
        let textLabel = LLRoundRectLabel(frame: CGRect(x: 0, y: 0, width: 80 + CGFloat(indexPath.row), height: 20))
        textLabel.text = "标签\(indexPath.section)\(indexPath.row)"
        cell.addSubview(textLabel)
        return cell
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
